package Main;

import java.awt.BorderLayout;
import java.awt.Insets;

import javax.swing.border.EmptyBorder;

import EventManager.EventManager;
import GameFiles.GameManager;
import PlayerManager.Player;
import PlayerManager.PlayerManager;

/*
 * Defines hold the global statics and defines.
 */
public class Defines {
	public static int TIMER_DELAY = 1000;
	public static int MINIMUM_BID_RESET = 500;
	public static int SINGLE_ROW_COLUMN_MODIFIER = 1;
	public static int LOTTERY_PILE_RESET_VAL = 0;
	public static int BONUS_PILE_RESET_VAL = 0;
	public static int PRINTABLE_PLAYER_ID_OFFSET = 1;
	public static int ICON_WIDTH = 75;
	public static int EMPTY_BORDER_PADDING = 5;
	public static int VERTICAL_PADDING = 10;
	public static int LOAN_AMOUNT = 1000;
	public static int CONST_TEST2 = 1;
	// TODO : add the acronyms for the singletons.
	public static GameManager OO = GameManager.getInstance();
	public static GameManager GM = GameManager.getInstance();
	// public static GameTimer GT = GameManager.getInstance().GameTimer;
	public static EventManager EVM = EventManager.getInstance();
	public static PlayerManager PLM = PlayerManager.getInstance();

	public static Player CP() {
		return PlayerManager.getInstance().getPlayerList().get(
				PlayerManager.getInstance().GetCurrentPlayerTurn());

	}
	public static BorderLayout getHeightStackedBorderLayout(){
		return new BorderLayout(0,VERTICAL_PADDING);
	}
	public static EmptyBorder getEmptyBorderConstraints() {
		return new EmptyBorder( new Insets(EMPTY_BORDER_PADDING, EMPTY_BORDER_PADDING,
				EMPTY_BORDER_PADDING, EMPTY_BORDER_PADDING));
	}
	public static String padAlign(String string, int fieldLength, char padding,
			boolean alignRight) {
		int length = fieldLength - string.length();

		if (length <= 0)
			return string.substring(0, string.length());

		StringBuffer buffer = new StringBuffer(fieldLength);

		for (int i = 0; i < length; i++)
			buffer.append(padding);

		if (alignRight)
			buffer.append(string);
		else
			buffer.insert(0, string);

		return new String(buffer);
	}
	
	
	  public static void main(String[] argv) {
		    String[] mesg = {"JavaFun", "JavaFun!" };
		    for (int i=0; i<mesg.length; i++) {
		      System.out.println("Input String \"" + mesg[i] + "\"");
		      dump(StringAlign.JUST_LEFT, 5,
		        new StringAlign(5, StringAlign.JUST_LEFT).format(mesg[i]));
		      dump(StringAlign.JUST_LEFT, 10,
		        new StringAlign(10, StringAlign.JUST_LEFT).format(mesg[i]));
		      dump(StringAlign.JUST_CENTER, 5,
		        new StringAlign(5, StringAlign.JUST_CENTER).format(mesg[i]));
		      dump(StringAlign.JUST_CENTER, 10,
		        new StringAlign(10, StringAlign.JUST_CENTER).format(mesg[i]));
		      dump(StringAlign.JUST_RIGHT, 5,
		        new StringAlign(5, StringAlign.JUST_RIGHT).format(mesg[i]));
		      dump(StringAlign.JUST_RIGHT, 10,
		        new StringAlign(10, StringAlign.JUST_RIGHT).format(mesg[i]));
		    }
		  }

		  private static void dump(int format, int len, String s) {
		    System.out.print((char)format + "[" + len + "]");
		    System.out.print(" ==> \"");
		    System.out.print(s);
		    System.out.print('"');
		    System.out.println();
		  }
	// omit because other things need to be initialized
	// MUST BE CALLED AFTER CP because it relies that
	// PlayerManager.getInstance() has been instantiated
	// public static GameFrame GF = GameFrame.getInstance();
}
